/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * UltimatumGlobalParametersComponent.java
 *
 * Created on 15/Dez/2011, 19:11:12
 */

package intopo.game.impl.ultimatum;

import intopo.game.gui.AbstractGlobalParametersComponent;
/**
 *
 * @author <a href="mailto:mariano.pedro@gmail.com">Pedro Mariano</a>
 *
 * @version 1.0 15/Dez/2011
 */
public class UltimatumGlobalParametersComponent
	extends AbstractGlobalParametersComponent
{

	/** Creates new form UltimatumGlobalParametersComponent */
	public UltimatumGlobalParametersComponent ()
	{
		initComponents ();
	}

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
   // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
   private void initComponents() {
      java.awt.GridBagConstraints gridBagConstraints;

      deterministicPanel = new javax.swing.JPanel();
      panel1 = new javax.swing.JPanel();
      jLabel1 = new javax.swing.JLabel();
      flipProbabilityAcceptDivisionFormattedTextField = new javax.swing.JFormattedTextField();
      stdevPanel = new javax.swing.JPanel();
      jLabel2 = new javax.swing.JLabel();
      stddevDivisionProposalFormattedTextField = new javax.swing.JFormattedTextField();

      setBorder(javax.swing.BorderFactory.createTitledBorder("global parameters"));
      setLayout(new java.awt.GridBagLayout());

      deterministicPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("deterministic strategies"));
      deterministicPanel.setLayout(new java.awt.GridBagLayout());

      panel1.setLayout(new java.awt.BorderLayout());

      jLabel1.setText("Flip probability accept division: ");
      panel1.add(jLabel1, java.awt.BorderLayout.CENTER);

      flipProbabilityAcceptDivisionFormattedTextField.setColumns(5);
      flipProbabilityAcceptDivisionFormattedTextField.setValue(new Float (UltimatumDeterministicStrategy.Parameters.flipProbabilityAcceptDivision));
      flipProbabilityAcceptDivisionFormattedTextField.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
         public void propertyChange(java.beans.PropertyChangeEvent evt) {
            flipProbabilityAcceptDivisionFormattedTextFieldPropertyChange(evt);
         }
      });
      panel1.add(flipProbabilityAcceptDivisionFormattedTextField, java.awt.BorderLayout.EAST);

      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
      deterministicPanel.add(panel1, gridBagConstraints);

      stdevPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("standard deviation normal distribution"));
      stdevPanel.setLayout(new java.awt.BorderLayout());

      jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
      jLabel2.setText("Division proposal gene: ");
      stdevPanel.add(jLabel2, java.awt.BorderLayout.CENTER);

      stddevDivisionProposalFormattedTextField.setColumns(5);
      stddevDivisionProposalFormattedTextField.setToolTipText("standard deviation of the normal distribution used to mutate the division proposal gene");
      stddevDivisionProposalFormattedTextField.setValue(new Float (UltimatumDeterministicStrategy.Parameters.stddevDivisionProposal));
      stddevDivisionProposalFormattedTextField.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
         public void propertyChange(java.beans.PropertyChangeEvent evt) {
            stddevDivisionProposalFormattedTextFieldPropertyChange(evt);
         }
      });
      stdevPanel.add(stddevDivisionProposalFormattedTextField, java.awt.BorderLayout.EAST);

      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
      deterministicPanel.add(stdevPanel, gridBagConstraints);

      add(deterministicPanel, new java.awt.GridBagConstraints());
   }// </editor-fold>//GEN-END:initComponents

	 private void stddevDivisionProposalFormattedTextFieldPropertyChange (java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_stddevDivisionProposalFormattedTextFieldPropertyChange
		if (evt.getPropertyName ().equals ("value")) {
			final float value = (Float) this.stddevDivisionProposalFormattedTextField.getValue ();
			final boolean ok = value >= 0;
			if (ok) {
				UltimatumDeterministicStrategy.Parameters.stddevDivisionProposal = value;
			}
			this.update (this.stddevDivisionProposalFormattedTextField, ok);
		}
	 }//GEN-LAST:event_stddevDivisionProposalFormattedTextFieldPropertyChange

	 private void flipProbabilityAcceptDivisionFormattedTextFieldPropertyChange (java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_flipProbabilityAcceptDivisionFormattedTextFieldPropertyChange
		if (evt.getPropertyName ().equals ("value")) {
			final float value = (Float) this.flipProbabilityAcceptDivisionFormattedTextField.getValue ();
			final boolean ok = value >= 0 && value <= 1;
			if (ok) {
				UltimatumDeterministicStrategy.Parameters.flipProbabilityAcceptDivision = value;
			}
			this.update (this.flipProbabilityAcceptDivisionFormattedTextField, ok);
		}
	 }//GEN-LAST:event_flipProbabilityAcceptDivisionFormattedTextFieldPropertyChange


   // Variables declaration - do not modify//GEN-BEGIN:variables
   private javax.swing.JPanel deterministicPanel;
   private javax.swing.JFormattedTextField flipProbabilityAcceptDivisionFormattedTextField;
   private javax.swing.JLabel jLabel1;
   private javax.swing.JLabel jLabel2;
   private javax.swing.JPanel panel1;
   private javax.swing.JFormattedTextField stddevDivisionProposalFormattedTextField;
   private javax.swing.JPanel stdevPanel;
   // End of variables declaration//GEN-END:variables

}

// Local Variables:
// mode: java
// mode: flyspell-prog
// ispell-local-dictionary: "british"
// End:
